Skip to content

[stable35] fix(settings): only save valid completed birth dates from the picker - #66431

Open
backportbot[bot] wants to merge 1 commit into
stable35from
backport/65197/stable35
Open

backportbot[bot] wants to merge 1 commit into
stable35from
backport/65197/stable35

Conversation

@backportbot

@backportbot backportbot Bot commented Nov 6, 2026

Copy link
Copy Markdown

Backport of PR #65197

Typing a birth date in Personal info garbled the day/month segments as
soon as the year was entered and could silently store a wrong date
(Fixes #49303). Root causes and what this changes, including the
lessons learned while fixing it:

- Wrong event contract: NcDateTimePickerNative emits the legacy
  `input` event with `null` on every partial keystroke (@nextcloud/vue
  8.x, via useModelMigration) and only forwards the raw native
  InputEvent in 9.x, so a listener on `input` either crashed on null
  (`e.getDate()` TypeError on every keystroke) or never receives a
  Date at all. `update:modelValue` carries `Date|null` on both major
  versions, so the handler now listens to that and ignores null
  (partially filled input).

- Mid-typing state updates garble the native input: Chrome completes
  and normalizes the date early during year entry, so updating the
  component model on every emitted value changes the `:model-value`
  prop while the user types; each programmatic `input.value` patch
  resets the browser's segment editing state and the following digits
  land in the wrong segments. The state update and save now run inside
  the existing 500ms debounce, so the prop stays stable during a
  typing burst and only a settled value is accepted.

- Empty birth date produced an Invalid Date that reached the picker as
  `0NaN-NaN-NaN` (rejected by the browser, but noisy and wasted
  renders). The display path is now null-safe.

- Out-of-range years: the browser clamps overflowing year segments
  (e.g. a 7-digit year) to the ECMAScript Date maximum 275760-09-13,
  and the native input still accepts typing years wider than 4 digits.
  Values outside years 1..9999 are now discarded before saving, and
  `min`/`max` are passed to the picker so the browser flags and
  sanitizes such entries in the field.

- JS quirk: `new Date(1, 0, 1)` maps years 0-99 to 1900+, so the min
  boundary is built with `setFullYear(1, 0, 1)`.

- Testing lesson: Vue logs handler TypeErrors via console.error
  instead of rethrowing, so naive "does not throw" specs pass even
  with the original bug; the regression specs therefore assert saved
  payloads positively and spy on console.error (mutation-verified
  against the original code).

Assisted-by: OpenCode:zai/glm-5.3
Signed-off-by: WSHAPER <42714629+WSHAPER@users.noreply.github.com>
@backportbot
backportbot Bot requested a review from a team as a code owner November 6, 2026 20:24
@backportbot
backportbot Bot requested review from WSHAPER, kristian-zendato, pringelmann and susnux and removed request for a team November 6, 2026 20:24
@backportbot backportbot Bot added bug 3. to review Waiting for reviews feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.) AI assisted labels Nov 6, 2026
@backportbot backportbot Bot added this to the Nextcloud 35.0.3 milestone Nov 6, 2026
This was referenced Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted bug feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants